package cn.cvs.service.sysUser;

import cn.cvs.dao.SysUserMapper;
import cn.cvs.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 许欣
 * 时间：2022/5/1 16:13
 * 描述：
 */
@Service
public class UserService {
    @Autowired
    private SysUserMapper sysUserMapper;
    //判断用户是否存在
    public boolean isUserExist(Integer id) {
        if (sysUserMapper.getUserById(id) == null) {
            return false;
        } else {
            return true;
        }
    }
    //根据提供的用户名拿密码
    public String getPasswordByUsername(Integer id) {
        return sysUserMapper.getUserById(id).getPassword();
    }
    //修改某一用户的密码
    public void modifyPasswordByUsername(Integer id, String pwd) {
        SysUser user = sysUserMapper.getUserById(id);
        user.setId(id);
        user.setPassword(pwd);
        sysUserMapper.updatePwd(id,pwd);
    }

}
